/*
 * consumer_test.c
 *
 *  Created on: Jun 26, 2009
 *      Author: root
 */

#include "consumer_test.h"
#include "consumer.h"
#include "producer_consumer.h"
#include "log.h"
#include "common.h"
#include <pthread.h>
#include <stdlib.h>

void * consumer_test(void * data)
{
   request_list_container_t * list_container = initContainer(LIST_SIZE);

   request_t * req;
   unsigned int index = 0;

   for (index = 0; index < TEST_AMOUNT; ++index)
   {
      req = (request_t *)malloc(sizeof(request_t));

      consume(list_container, req);

      writeLog(SOURCE_CONSUMER_TEST, req);

      free(req->req);
      req->req = NULL;
      free(req);
      req = NULL;
   }

   sem_post(&exitSem);

   pthread_exit(NULL);

   return NULL;
}
